fix: round playback speed readback to fix floating-point display (#3460) #3602
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #3460 — Playback Speed indicator shows too many digits (e.g.
"1.1500000000000001x"instead of"1.15x").Root Cause
The
playbackSpeed()function inplayer.jswas returning rawvideo.playbackRatevalues after setting speed. Due to IEEE 754 floating-point arithmetic (1.1 + 0.05 = 1.1500000000000001), the return value had excessive precision.The read path (line 111) already rounds with
Number(x.toFixed(2)), but the write-and-readback path (lines 123, 126) did not. When callers concatenated this raw value with'x'(e.g.showStatus(speed + 'x')), it produced strings like"1.1500000000000001x"that bypassedshowStatus()'stypeof number→toFixed(2)guard.Fix
Apply the same
Number(x.toFixed(2))rounding to the readback values at lines 123 and 126 — consistent with the existing pattern at line 111.2 lines changed in 1 file.
Testing
(1.1500000000000001).toFixed(2)returns"1.15"playbackSpeed()return value for displayvideo.playbackRatevalues set on the elementBrowsers
Affects all browsers (IEEE 754 is universal), reported on Firefox.
Made with Cursor